<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Zookeeper 性能调优指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border: 1px solid rgba(102, 126, 234, 0.3);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 8px;
            margin-top: -8px;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 1.5rem;
            margin: 1.5rem 0;
            border-radius: 0 8px 8px 0;
        }
        
        .metric-card {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            text-align: center;
            transition: all 0.3s ease;
        }
        
        .metric-card:hover {
            transform: scale(1.05);
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .metric-icon {
            width: 60px;
            height: 60px;
            margin: 0 auto 1rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
        }
        
        code {
            background: rgba(102, 126, 234, 0.1);
            padding: 2px 8px;
            border-radius: 4px;
            font-family: 'Consolas', 'Monaco', monospace;
            color: #5a67d8;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    <i class="fas fa-cogs mr-4"></i>Zookeeper 性能调优指南
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    深入探索分布式协调服务的性能优化策略，打造高效稳定的 Zookeeper 集群
                </p>
                <div class="mt-10 flex justify-center space-x-4">
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-rocket mr-2"></i>性能提升
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-shield-alt mr-2"></i>稳定可靠
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-chart-line mr-2"></i>实时监控
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="max-w-4xl mx-auto mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">调</span>优 Zookeeper 的性能涉及多个方面，包括 JVM 参数调整、配置优化、网络配置、硬件资源管理、监控和故障排除等。根据具体的应用需求和集群负载，调整上述参数和策略，可以显著提高 Zookeeper 的性能和稳定性。
                </p>
            </div>
        </div>

        <!-- Performance Metrics -->
        <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-16">
            <div class="metric-card">
                <div class="metric-icon">
                    <i class="fas fa-memory"></i>
                </div>
                <h3 class="text-xl font-bold text-gray-800 mb-2">内存优化</h3>
                <p class="text-gray-600">JVM堆内存调优</p>
            </div>
            <div class="metric-card">
                <div class="metric-icon">
                    <i class="fas fa-network-wired"></i>
                </div>
                <h3 class="text-xl font-bold text-gray-800 mb-2">网络配置</h3>
                <p class="text-gray-600">低延迟高带宽</p>
            </div>
            <div class="metric-card">
                <div class="metric-icon">
                    <i class="fas fa-database"></i>
                </div>
                <h3 class="text-xl font-bold text-gray-800 mb-2">存储优化</h3>
                <p class="text-gray-600">SSD高速存储</p>
            </div>
            <div class="metric-card">
                <div class="metric-icon">
                    <i class="fas fa-tachometer-alt"></i>
                </div>
                <h3 class="text-xl font-bold text-gray-800 mb-2">实时监控</h3>
                <p class="text-gray-600">性能指标追踪</p>
            </div>
        </div>

        <!-- Optimization Architecture Diagram -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 text-center">
                <i class="fas fa-sitemap mr-3 text-purple-600"></i>Zookeeper 性能优化架构
            </h2>
            <div class="mermaid">
                graph TB
                    A[Zookeeper性能优化] --> B[内存与文件系统]
                    A --> C[配置参数优化]
                    A --> D[网络配置]
                    A --> E[硬件资源]
                    A --> F[监控与故障排除]
                    A --> G[集群配置]
                    
                    B --> B1[JVM参数调整]
                    B --> B2[文件系统设置]
                    
                    C --> C1[事务日志与快照]
                    C --> C2[会话超时]
                    C --> C3[连接与线程]
                    
                    D --> D1[网络带宽]
                    D --> D2[网络延迟]
                    
                    E --> E1[CPU资源]
                    E --> E2[内存资源]
                    
                    F --> F1[监控工具]
                    F --> F2[故障排除]
                    
                    G --> G1[集群规模]
                    G --> G2[领导者选举]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                    style B fill:#f3e8ff,stroke:#667eea,stroke-width:2px
                    style C fill:#f3e8ff,stroke:#667eea,stroke-width:2px
                    style D fill:#f3e8ff,stroke:#667eea,stroke-width:2px
                    style E fill:#f3e8ff,stroke:#667eea,stroke-width:2px
                    style F fill:#f3e8ff,stroke:#667eea,stroke-width:2px
                    style G fill:#f3e8ff,stroke:#667eea,stroke-width:2px
            </div>
        </div>

        <!-- Section 1: Memory and File System -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12 card-hover">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 section-title">
                <i class="fas fa-memory mr-3 text-purple-600"></i>1. 调整内存和文件系统设置
            </h2>
            
            <div class="mb-8">
                <h3 class="text-2xl font-semibold text-gray-700 mb-4">
                    <i class="fas fa-coffee mr-2 text-purple-500"></i>1.1 JVM 参数
                </h3>
                
                <div class="highlight-box">
                    <h4 class="text-xl font-semibold text-gray-700 mb-3">
                        <i class="fas fa-database mr-2"></i>堆内存大小
                    </h4>
                    <p class="text-gray-600 leading-relaxed mb-3">
                        根据节点的负载和数据量配置适当的 JVM 堆内存大小。可以使用 <code>-Xms</code> 和 <code>-Xmx</code> 参数来设置初始堆大小和最大堆大小。
                    </p>
                    <div class="bg-gray-100 rounded-lg p-4 font-mono text-sm">
                        <i class="fas fa-terminal mr-2 text-purple-600"></i>
                        -Xms4g -Xmx4g <span class="text-gray-500"># 初始和最大堆大小均为 4 GB</span>
                    </div>
                </div>
                
                <div class="highlight-box mt-6">
                    <h4 class="text-xl font-semibold text-gray-700 mb-3">
                        <i class="fas fa-recycle mr-2"></i>GC 设置
                    </h4>
                    <p class="text-gray-600 leading-relaxed mb-3">
                        选择合适的垃圾回收器并调整 GC 参数。例如，可以使用 G1GC 来改善垃圾回收性能。
                    </p>
                    <div class="bg-gray-100 rounded-lg p-4 font-mono text-sm">
                        <i class="fas fa-terminal mr-2 text-purple-600"></i>
                        -XX:+UseG1GC <span class="text-gray-500"># 启用 G1 垃圾回收器</span>
                    </div>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold text-gray-700 mb-4">
                    <i class="fas fa-hdd mr-2 text-purple-500"></i>1.2 文件系统设置
                </h3>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-lg p-6">
                        <h4 class="text-xl font-semibold text-gray-700 mb-3">
                            <i class="fas fa-folder-open mr-2"></i>数据目录
                        </h4>
                        <p class="text-gray-600 leading-relaxed">
                            配置 <code>dataDir</code> 和 <code>dataLogDir</code> 参数，指定数据和事务日志目录。确保这些目录位于高速 SSD 上，以提高 I/O 性能。
                        </p>
                    </div>
                    
                    <div class="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-lg p-6">
                        <h4 class="text-xl font-semibold text-gray-700 mb-3">
                            <i class="fas fa-layer-group mr-2"></i>文件系统缓存
                        </h4>
                        <p class="text-gray-600 leading-relaxed">
                            调整文件系统缓存设置，确保高效的读写操作。
                        </p>
                    </div>
                </div>
            </div>
        </div>

        <!-- Section 2: Configuration Parameters -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12 card-hover">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 section-title">
                <i class="